import type {FormInstance, ValidatedError} from "@arco-design/web-vue";

type SubmitType = (bool: boolean) => void

const useFormSubmit = (formRef: FormInstance) => {

    return (callBack: SubmitType) => {
        formRef.value?.validate((errors: undefined | Record<string, ValidatedError>) => {

            if (errors === undefined) {
                callBack(true)
            } else {
                callBack(false)
            }
        })
    }
}

export default useFormSubmit